<?php

namespace App\Exceptions;

use Exception;
use Throwable;

class ApiException extends Exception
{
    public function __construct(string $message = "", int $code = 400, Throwable $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }

    public function render($request, Exception $exception)
    {
        if ($exception instanceof ApiException) {
            return response()->json(['code'=>$exception->getCode(), 'msg'=> $exception->getMessage(), 'data'=>'']);//自定义返回
        }

        return parent::render($request, $exception);
    }



}
